-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require users of msg_send!
to specify the return type
#83
Require users of msg_send!
to specify the return type
#83
Conversation
This is a breaking change, to prevent misuses such as SSheldon#62
I found after making this patch #62 (comment) which suggests an alternative idea: requiring the return type to implement some (unsafe) trait that is not implemented for |
@SimonSapin you mention in rust-lang/rust#65355 (comment):
If we remove the match and panic expressions, will that help? If so, I can explore some refactor there. Would a trivial reordering like this prevent the types from being unified? let r = $crate::__send_message(...);
if r.is_err() {
panic!("{}", r.as_ref().unwrap_err());
}
return r.unwrap(); |
I don’t know, it’s worth trying |
Is there a reason the panic is part of a macro expansion rather than in |
Just tested that change on rustc 1.35 and confirmed that with it, I get a compile error at the usage site of the macro:
Neat! Didn't realize that I could get the misuse case to compile error. I think we should just make a change like that. |
@SimonSapin I wanted the panic to report the line and file where |
Re line numbers I see, that makes sense. It’s rather extreme, but how would you feel about yanking all current versions? See rust-lang/rust#65355 (comment) |
Regarding yanking, I wouldn't love that, but we can keep it under consideration. First we'll have to figure out how the heck to get everyone to fix the existing misuses of Closing this in favor of df957f2, a more backwards compatible way to prevent this. |
Just noticed that this was published as Edit okay, I found #62, ignore me ✌️ |
@cmyr sorry for the inconvenience! A bit more on my reasoning in rust-lang/rust#65355 (comment) and #86 (comment). If I had published the change as 0.3, you would have undefined behavior when Let me know if I can help the crate you're using get fixed! We tested the biggest users of objc and made sure they had fixes ready, but the crate you're using may have slipped under the radar. |
@SSheldon no worries, the rationale makes sense, the fix wasn't that painful. I'm glad I can do edit: here's an example where I've casted an edit edit: also I assume you've seen https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.html? I found it really interesting. :) |
This is a breaking change, to prevent misuses such as #62.